﻿using System;
using System.IO;

namespace Heimdallr.Net
{  
    public class HttpMultipartWorkingItem
    {
        #region Field

        private readonly string boundary;
        private readonly Stream source;
        private readonly int maxPartLength;
        private readonly object userState;

        #endregion

        #region Property
         
        public string Boundary
        {
            get { return this.boundary; }
        }
         
        public Stream Source
        {
            get { return this.source; }
        }

        public int MaxPartLength
        {
            get { return this.maxPartLength; }
        }
         
        public object UserState
        {
            get { return this.userState; }
        }

        #endregion

        #region Constructor
         
        public HttpMultipartWorkingItem(string boundary, Stream source, int maxPartLength)
            : this(boundary, source, maxPartLength, null)
        {
        }

        public HttpMultipartWorkingItem(string boundary, Stream source, int maxPartLength, object userState)
        {
            if (boundary == null)
                throw new ArgumentNullException("boundary");

            if (boundary.Length == 0)
                throw new ArgumentException("Can not accept empty string.", "boundary");

            if (source == null)
                throw new ArgumentNullException("source");

            if (!source.CanRead)
                throw new ArgumentException("Stream is not readable.", "source");
             
            this.boundary = boundary;
            this.source = source;
            this.maxPartLength = maxPartLength;
            this.userState = userState;
        }

        #endregion
    }
}
